#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <vector>
using namespace std;

class Solution {
    vector<vector<int>> ret;
    vector<int> path;
    bool check[10] = { 0 };
public:
    void dfs(vector<int>& nums) {
        if (path.size() == nums.size()) {
            ret.push_back(path);
        }
        for (int i = 0; i < nums.size(); i++) {
            if (check[i] == false) {
                check[i] = true;
                path.push_back(nums[i]);
                dfs(nums);
                path.pop_back();
                check[i] = false;
            }
        }
    }
    vector<vector<int>> permute(vector<int>& nums) {
        dfs(nums);
        return ret;
    }
};

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int ret = 0;
        for (int i = 0; i < 32; i++)
        {
            int count = 0;
            for (auto e : nums)
            {
                if ((e >> i) & 1) count++;
            }
            if (count % 3 == 1) ret |= (1 << i);
        }
        return ret;
    }
};